package me.hai.uitest.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;

@Service
public class TestService {

	final String SERVICE_NAME = "springboot";

	@Autowired
	RestTemplate restTemplate;

	@HystrixCommand(fallbackMethod = "fallbackSearchAll")
	public String hello() {
		return restTemplate.getForObject("http://" + SERVICE_NAME + "/user/1", String.class);
	}

	private String fallbackSearchAll() {

		System.out.println("HystrixCommand fallbackMethod handle!");

		return "TestHystrix";

	}
}
